package org.example.test;


import java.util.HashMap;
import java.util.Scanner;

public class xiaomi1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        scanner.nextLine();
        char[] likeStr = new char[m];
        HashMap<Character, Integer> likeChar = new HashMap<>();
        for (int i = 0; i < m; i++) {
            likeStr[i] = scanner.next().charAt(0);
            likeChar.put(likeStr[i], n);
        }

        scanner.nextLine();
        String str = scanner.nextLine().trim();
        StringBuilder stringBuilder = new StringBuilder(str);

        char ch;
        int leftIndex = 0;
        int rightIndex = 0;
        for (int i = 0; i < stringBuilder.length(); i++) {
            ch = stringBuilder.charAt(i);
            if (likeChar.containsKey(ch)) {
                continue;
            } else {
                leftIndex = i - 1;
                rightIndex = i + 1;
                while (rightIndex < stringBuilder.length() || leftIndex >= 0) {
                    if (leftIndex >= 0) {
                        if (likeChar.containsKey(str.charAt(leftIndex))) {
                            stringBuilder.deleteCharAt(i);
                            stringBuilder.insert(i, str.charAt(leftIndex));
                            break;
                        } else {
                            leftIndex--;
                        }
                    }
                    if (rightIndex < stringBuilder.length()) {
                        if (likeChar.containsKey(str.charAt(rightIndex))) {
                            stringBuilder.deleteCharAt(i);
                            stringBuilder.insert(i, str.charAt(rightIndex));
                            break;
                        } else {
                            rightIndex++;
                        }
                    }
                }
            }
        }

        String s = stringBuilder.toString();
        System.out.println(s);


    }


}
